home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1995 January / 1995-01b.d64 / disk display (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  7KB  |  193 lines

  1. 100 rem ******************************
  2. 110 rem
  3. 120 rem    d i s k   d i s p l a y
  4. 130 rem
  5. 140 rem   display any track & sector
  6. 150 rem      to screen or printer
  7. 160 rem
  8. 170 rem      by: robert w. baker
  9. 180 rem    from q-link disk # 160
  10. 190 rem
  11. 200 rem ******************************
  12. 210 poke53280,15:poke53281,15
  13. 220 print"[147][153]";spc(13);"initializing"
  14. 230 close 15: open 15,8,15: print#15,"u0>m9"
  15. 240 input#15,en: if en<>31 then dt=0: goto 270
  16. 250 dt=1: print#15,"u0>h0": input#15,en: if en=31 then 270
  17. 260 print"[152]changing 1571 disk to double sided mode": print#15,"u0>m1"
  18. 270 close 15: dim a$(255),b$(35),ts(70)
  19. 280 ns$=chr$(13): nl$=chr$(0): sp$=chr$(160): hx$="0123456789abcdef"
  20. 290 t$(1)="seq": t$(2)="prg": t$(3)="usr": t$(4)="rel"
  21. 300 lx=8: poke 981,15: poke 65280,0: if peek(65280)<>0 then 320: rem c64
  22. 310 if peek(215)=128 then lx=16: rem 80 column c128
  23. 320 for j=1 to 17: ts(j)=21: next j: for j=18 to 24: ts(j)=19: next j
  24. 330 for j=25 to 30: ts(j)=18: next j: for j=31 to 35: ts(j)=17: next j
  25. 340 for j=36 to 70: ts(j)=ts(j-35): next j: goto 510
  26. 350 close 15: print"[147]        d i s k   d i s p l a y[152]": gosub 1640
  27. 360 if pd=3 then print spc(16);"display[146]"
  28. 370 if pd=4 then print spc(17);"print[146]"
  29. 380 print spc(7);"1 - block(s) at trk & sec"
  30. 390 print spc(7);"2 - blocks in file"
  31. 400 print spc(7);"3 - links  in file"
  32. 410 print spc(7);"4 - block avail map (bam)"
  33. 420 print spc(7);"5 - directory"
  34. 430 print spc(7);"q = quit";
  35. 440 if pd=3 then print",   p = print output"
  36. 450 if pd=4 then print",   d = display output"
  37. 460 gosub 1640: print" desired function: ";
  38. 470 get z$: if z$="" then 470
  39. 480 if z$="q" then print z$: goto 2010
  40. 490 if z$="p" and pd=3 then pd=4: sc$=ns$: goto 520
  41. 500 if z$<>"d" or pd<>4 then 530
  42. 510 pd=3: sc$="[147]"
  43. 520 close 4: open 4,pd: goto 350
  44. 530 f=val(z$): if f<1 or f>5 then 470
  45. 540 print z$: on f goto 550,630,630,660,660
  46. 550 print"[147][152]display block(s) at track & sector:": gosub 1640
  47. 560 print"enter starting track & sector numbers"
  48. 570 print"in decimal, or in hex preceded by a"
  49. 580 print"dollar sign ($).": gosub 1640
  50. 590 print"starting  track#: ";: gosub 1700: if x$=sp$ then 350
  51. 600 t=n: if t<1 or t>70 then 550
  52. 610 print spc(9);"sector#: ";: gosub 1700: s=n: if n<0 or n>ts(t) then 550
  53. 620 goto 660
  54. 630 print"filename: ";: gosub 1690: if x$=sp$ then 350
  55. 640 fl$=left$(x$+"[160][160][160][160][160][160][160][160][160][160][160][160][160][160][160][160]",16): rem <-- 16 shifted spaces
  56. 650 print"[147]searching for file: ";fl$
  57. 660 open 15,8,15,"i0": input#15,en,em$,et,es: if en=0 then 690
  58. 670 if en<>21 and et<>18 and es<>0 then gosub 2000: goto 1200
  59. 680 print"please insert disk & reselect function!": goto 1200
  60. 690 close 2: open 2,8,2,"#0": gosub 1990: if en>0 then 1200
  61. 700 on f goto 900,710,710,1240,1240
  62. 710 t=18: s=1
  63. 720 gosub 1950: if en>0 then 1200
  64. 730 t=-1: for j=2 to 226 step 32: ft=asc(a$(j)) and 7: if ft=0 then 800
  65. 740 n=0: for i=1 to 16: if mid$(fl$,i,1)<>a$(j+i+2) then n=1: i=16
  66. 750 next i: if n=1 then 800
  67. 760 n=asc(a$(j+28))+(asc(a$(j+29))*256)
  68. 770 if n=0 then print"zero length file": ft=-1: goto 790
  69. 780 t=asc(a$(j+1)): s=asc(a$(j+2)): t1=asc(a$(j+19)): s1=asc(a$(j+20))
  70. 790 j=256
  71. 800 next j: bk=1: if ft=-1 then 1200
  72. 810 if t>0 then 840
  73. 820 t=nt: s=ns: if t>0 then 720
  74. 830 print"file not found": goto 1200
  75. 840 if ft<>4 then 900
  76. 850 print"ok, file found....."
  77. 860 print"selected file is a relative data file"
  78. 870 print"want data (d) or side sectors (s): ";
  79. 880 get c$: if c$="s" then t=t1: s=s1: goto 900
  80. 890 if c$<>"d" then 880
  81. 900 gosub 1800
  82. 910 if dt=0 and t>35 then 1180
  83. 920 gosub 1980: if en>0 then 1200
  84. 930 if f<3 then 990
  85. 940 n=1: gosub 1960: n=bk: l=6: gosub 1650: bk=bk+1: n=t: l=5: gosub 1910
  86. 950 n=s: gosub 1910: print#4: t=nt: s=ns: if t=0 then 1190
  87. 960 get z$: if z$="q" then 350
  88. 970 if pd=3 then ll=ll+1: if ll=16 then 1160
  89. 980 goto 910
  90. 990 l4=lx: if pd=4 then l4=16
  91. 1000 jj=256-l4: for j=0 to jj step l4
  92. 1010 b$=": ": n=j: gosub 1930: a$=c$+": "
  93. 1020 for i=0 to l4-1: get#2,a$(i): if a$(i)="" then a$(i)=nl$
  94. 1030 n=asc(a$(i)): gosub 1930: a$=a$+c$+" "
  95. 1040 if (n and 127)<32 then b$=b$+"[153][204][146][152]": goto 1060
  96. 1050 b$=b$+a$(i)
  97. 1060 next i: print#4,a$;b$: if pd=3 then ll=ll+1
  98. 1070 if j=0 then nt=asc(a$(0)): ns=asc(a$(1))
  99. 1080 get z$: if z$="q" then 1120
  100. 1090 if ll<16 or j>=jj then 1130
  101. 1100 gosub 1660: if z$="y" then gosub 1810: goto 1130
  102. 1110 print"[145]                       ": print"[145][145]";: rem <-- 23 spaces
  103. 1120 j=jj
  104. 1130 next j: t=nt: s=ns: if t=0 then 1190
  105. 1140 n=t: gosub 1930: print"next track:";t;"($";c$;"), sector:";s;
  106. 1150 n=s: gosub 1930: print "($";c$;")"
  107. 1160 gosub 1660: if z$="y" then 900
  108. 1170 goto 350
  109. 1180 print"disk drive cannot read tracks above 35": goto 1210
  110. 1190 print"last block in chain...": goto 1210
  111. 1200 if pd=4 then print"[147]done printing....."
  112. 1210 print"press <space> to return to main menu"
  113. 1220 get z$: if z$="" then 1220
  114. 1230 goto 350
  115. 1240 print"[147]reading disk block avail map (bam)"
  116. 1250 t=18: s=0: gosub 1950: if en>0 then 1200
  117. 1260 a$="": for n=144 to 159: a$=a$+a$(n): next n: b$=a$(162)+a$(163)
  118. 1270 gosub 1800: bk=1: if f=5 then 1510
  119. 1280 jj=17: for j=4 to 140 step 4: n=bk: l=2: gosub 1650
  120. 1290 for l=1 to 3: n=asc(a$(j+l)): for i=0 to 7: if l<3 then 1330
  121. 1300 if i+17<=ts(bk) then 1330
  122. 1310 if i<5 then for n=i to 4: print#4," ";:next n
  123. 1320 i=7: goto 1350
  124. 1330 if (n and 2^i)>0 then print#4,"[153][204][146][152]";: goto 1350
  125. 1340 print#4,"[150][204][146][152]";
  126. 1350 next i,l
  127. 1360 n=ts(bk): l=4: gosub 1650: n=asc(a$(j)): gosub 1650: i=n
  128. 1370 n=ts(bk)-i: gosub 1650: print#4: bk=bk+1: if pd=3 then ll=ll+1
  129. 1380 get z$: if z$="q" then 1420
  130. 1390 if j=140 and a$(3)=nl$ then 1430
  131. 1400 if ll<jj then 1430
  132. 1410 gosub 1660: if z$="y" then jj=18: gosub 1800: goto 1430
  133. 1420 bk=-1: j=140
  134. 1430 next j: if bk<0 then 350
  135. 1440 if a$(3)=nl$ then 1200
  136. 1450 if dt=0 then 1180
  137. 1460 for j=1 to 35: b$(j)=a$(j+220): next j
  138. 1470 t=53: s=0: gosub 1980: if en>0 then 1200
  139. 1480 a$(3)=nl$: for j=1 to 35: a$(j*4)=b$(j)
  140. 1490 for i=1 to 3: get#2,z$: if z$="" then z$=nl$
  141. 1500 a$(j*4+i)=z$: next i,j: goto 1280
  142. 1510 t=nt: s=ns: gosub 1950: if en>0 then 1200
  143. 1520 for j=2 to 226 step 32: ft=asc(a$(j)) and 7: if ft=0 or ft>4 then 1600
  144. 1530 n=asc(a$(j+28))+(asc(a$(j+29))*256)
  145. 1540 c$="": for i=3 to 18: c$=c$+a$(j+i): next i
  146. 1550 l=5: gosub 1650: print#4,c$;"  ";t$(ft): if pd=3 then ll=ll+1
  147. 1560 get z$: if z$="q" then 1590
  148. 1570 if ll<16 then 1600
  149. 1580 gosub 1660: if z$="y" then gosub 1800: goto 1600
  150. 1590 t=-1: j=256
  151. 1600 next j: if t=-1 then 350
  152. 1610 if nt>0 then 1510
  153. 1620 goto 1200
  154. 1630 rem *****  subroutines *****
  155. 1640 print"[195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195]": return
  156. 1650 print#4,right$("        "+str$(n),l);" ";: return
  157. 1660 print"continue display (y/n): "
  158. 1670 get z$: if z$="y" or z$="n" then return
  159. 1680 goto 1670
  160. 1690 print"";sp$;"[157][157][157]";: input x$: return
  161. 1700 n=-1: gosub 1690: if x$=sp$ then return
  162. 1710 if left$(x$,1)="$" then 1740
  163. 1720 for j=1 to len(x$): c$=mid$(x$,j,1): if c$<"0" or c$>"9" then 1780
  164. 1730 next j: n=val(x$): return
  165. 1740 if len(x$)<2 then return
  166. 1750 n=0: for j=2 to len(x$): c$=mid$(x$,j,1): if c$<"0" then 1780
  167. 1760 if c$<="9" then n=n*16+val(c$): goto 1790
  168. 1770 if c$>="a" then if c$<="f" then n=n*16+asc(c$)-55: goto 1790
  169. 1780 j=99: n=-1
  170. 1790 next j: return
  171. 1800 if pd=4 then print"[147]printing selected disk data....."
  172. 1810 ll=0: on f goto 1890,1890,1820,1860,1850
  173. 1820 print#4,sc$;"block linkage in file: ";fl$: print#4
  174. 1830 print#4," block#    track#    sector#"
  175. 1840 print#4," ------   --------   --------": return
  176. 1850 print#4,sc$;"directory of: ";a$;"   id: ";b$: print#4: return
  177. 1860 print#4,sc$;"bam for disk: ";a$;"   id: ";b$: print#4
  178. 1870 print#4,"trk - sec -  11111111112 #sec free used"
  179. 1880 print#4,"   012345678901234567890 ---- ---- ----": return
  180. 1890 print#4,sc$;"track:";t;: n=t: gosub 1920
  181. 1900 print#4,", sector:";s;: n=s: gosub 1920: print#4: print#4: return
  182. 1910 gosub 1650
  183. 1920 gosub 1930: print#4,"($";c$;")";: return
  184. 1930 a1=int(n/16): a2=int(n-16*a1